package 剑指offer;

public class M5 {
    public int maxProduct(String[] words) {
        int[] data=new int[words.length];
        for (int i = 0; i < words.length; i++) {
            char[] middle=words[i].toCharArray();
            for (char c : middle) {
                if ((data[i]&(1<<(c-'a')))==0) {
                    data[i]+=1<<(c-'a');
                }
            }
        }
        int max_len=0;
        for (int i = 0; i < data.length; i++) {
            for (int j = i+1; j < data.length; j++) {
                if ((data[i]&data[j])==0) {
                    max_len=Math.max(max_len, words[i].length()*words[j].length());
                }
            }
        }
        return max_len;
    }
}
